#!/bin/bash
set -xe

if [ -z $1 ];then
	echo "Please input kernel source path"
	exit
fi

KERNEL_SRC_PATH=$1
NR_CPUS=`cat /proc/cpuinfo | grep 'processor' | wc -l`

# work in kernel source path
cd $KERNEL_SRC_PATH

# install necessay dependencies
apt-get install build-essential kernel-package   libncurses5-dev -y

# clear tmp file
#make mrproper

# copy config
cp /boot/config-`uname -r` ./.config

make oldconfig

# compile kernel
make -j$NR_CPUS

# install modules
make modules_install

# install
make install

# update grub
update-grub



